import Vue from 'vue'
import Vuex from 'vuex'

import user from './modules/user'
import setting from './modules/setting'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count: 101,
    name:'jexi',
    list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  },
  getters: {
    total:state=>state.list.reduce((a,b)=>a+b,0)
  },
  mutations: {
     addHand(state){
      state.count +=10
     },
     addCount (state) {
      state.count -=10 
    },
    addCount2(state,m){
      state.count +=m
    }
  },
  actions: {
    syncHandle({commit}, m) {
      setTimeout(() => {
        commit('addCount2', m)
      }, 1000)
    }
  },
  modules: {
    user,
    setting
  }
})
